package collections

/**
 *@author LikeYouDo
 *@date 2024/12/12 16:44
 */
fun main() {
    println(numbers.first())
    println(numbers.last())

    println(numbers.first { it % 2 == 0 })
    println(numbers.last { it % 2 != 0 })

    val words = listOf("foo", "bar", "baz", "faz")
    val empty = emptyList<String>()

    println(empty.firstOrNull())               // 3
    println(empty.lastOrNull())                          // 4


    println(words.firstOrNull { it.startsWith('f') })  // 5
    println(words.firstOrNull { it.startsWith('z') })  // 6
    println(words.lastOrNull { it.endsWith('f') })      // 7
    println(words.lastOrNull { it.endsWith('z') })      // 8
}